<?php
	class BrandAction extends Action {
		/**
		 * 显示品牌页
		 */
		public function index(){
			$db = M('brand');
			import("ORG.Util.Page");
			$count = $db->count();
			$Page = new Page($count,10);
			$show = $Page->show();
			$arr = $db->order('bid desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			$this->assign('typeData',$arr);
			$this->assign('page',$show);
			$this->display();
		}
		/**
		 * 添加品牌
		 */
		public function addBrand(){
			$this->display();
		}
		/**
		 *上传企业LOGO 
		 */
		public function upload (){
			import("ORG.Net.UploadFile");
			$upload = new UploadFile();
			$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
			$upload->savePath = './Update/BrandLogo/';
			$upload->saveRule = time();
			$upload->upload();
		    $arr = $upload->getUploadFileInfo();
		    $file =__ROOT__."/Update/BrandLogo/".$arr[0]['savename'];
		    echo $file;
		}
		/**
		 * 添加品牌
		 */
		public function add (){
			 $db = M('brand');
			 if($db->add($_POST)){
			 	echo json_encode(array('num'=>1,'mesa'=>'上传成功'));
			 }else{
			 	echo json_encode(array('num'=>0,'mesa'=>'上传失败'));
			 }
		}
	}

?>